﻿using System;
using System.Collections.Generic;
using System.Text;
using VietKinsNutrition.Data;
using DevExpress.XtraEditors;
using System.Windows.Forms;
using System.Data;

namespace VietKinsNutrition.Bussiness
{
    public class ClsTblGiaBLL : ClsBindingBLL
    {
        ClsTblGiaDAL ClsTblGiadal = new ClsTblGiaDAL();
        public DataTable ReturnTblSelectAll()
        {
            return ClsTblGiadal.SelectAll();
        }
        public void Insert(float Nhombot, float Nhomchao, float Nhatre, float Maugiao)
        {
            ClsTblGiadal.Insert(Nhombot, Nhomchao, Nhatre, Maugiao);
        }
        int _Id;

        public int Id
        {
            get { return _Id; }
            set { _Id = value; }
        }
        public void BingSource_InputControl(TextEdit TxtNhombot, TextEdit TxtNhomchao, TextEdit TxtNhatre, TextEdit TxtMaugiao, DataGridView Grid)
        {
            if (Grid.RowCount > 0)
            {
                this.Id = int.Parse(Grid.Rows[Grid.CurrentRow.Index].Cells["Id"].Value.ToString());
                TxtNhombot.Text = Grid.Rows[Grid.CurrentRow.Index].Cells["Nhombot"].Value.ToString();
                TxtNhomchao.Text = Grid.Rows[Grid.CurrentRow.Index].Cells["nhomchao"].Value.ToString();
                TxtNhatre.Text = Grid.Rows[Grid.CurrentRow.Index].Cells["Nhatre"].Value.ToString();
                TxtMaugiao.Text = Grid.Rows[Grid.CurrentRow.Index].Cells["Maugiao"].Value.ToString();
            }
        }

        public void Edit(float Nhombot, float Nhomchao, float Nhatre, float Maugiao)
        {
            ClsTblGiadal.Edit(this.Id, Nhombot, Nhomchao, Nhatre, Maugiao);
        }
    }
}
